/**

* <p>Title: OrdersItemsController.java</p>

* <p>Description: </p>

* <p>Copyright: Copyright (c) 2021</p>

* <p>Company: www.chinasofti.com</p>

* @author knowno

* @date 2021年3月11日

* @version 1.0

*/
package com.etc.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.etc.entity.Items;
import com.etc.util.AjaxResponse;
import com.etc.zmall.service.OrdersItemsService;
import com.github.pagehelper.PageInfo;

import io.swagger.annotations.Api;

/**
 * 
 * <p>
 * Title: OrdersItemsController
 * </p>
 * 
 * <p>
 * Description:
 * </p>
 * 
 * @author knowno
 * 
 * @date 2021年3月11日
 * 
 */
@RestController
@Api(value = "订单项接口类")
public class OrdersItemsController {
	// 注入一个service
	@Autowired
	private OrdersItemsService itemsService;

	@GetMapping(value = "api/items")
	public AjaxResponse<Items> listOrdersItems(String orderid,
			@RequestParam(name = "page", required = false, defaultValue = "1") int page,
			@RequestParam(name = "limit", required = false, defaultValue = "10") int limit) {
		PageInfo<Items> pageInfo = itemsService.getByPage(orderid, page, limit);
		AjaxResponse<Items> ar = new AjaxResponse<Items>(0, "success", (int) pageInfo.getTotal(), pageInfo.getList());
		return ar;
	}

	@GetMapping(value = "api/itemsmulti")
	public AjaxResponse<Items> listOrdersItemsmulti(String orderid,
			@RequestParam(name = "page", required = false, defaultValue = "1") int page,
			@RequestParam(name = "limit", required = false, defaultValue = "10") int limit) {
		PageInfo<Items> pageInfo = itemsService.getByPageMulti(orderid, page, limit);
		AjaxResponse<Items> ar = new AjaxResponse<Items>(0, "success", (int) pageInfo.getTotal(), pageInfo.getList());
		return ar;
	}
}
